package th.co.exat.uap.model;

import com.channgam.dbmlib.sql.MySQLJDBC;
import com.channgam.dbmlib.sql.iDataAdapter;
import java.util.ArrayList;
import java.util.List;
import th.co.exat.uap.config.Config;

public class Police {

    private static iDataAdapter i;
    private String id;
    private String parentId;
    private String fullName;
    private String shortName;

    public static List<Police> getPoliceList() throws Exception {
        List<Police> list = new ArrayList<Police>();
        i = new MySQLJDBC(Config.getMySqlHost(),
                Config.getMySqlUsername(),
                Config.getMySqlPassword(),
                Config.getMySqlDbname());
        i.connect();
        String sql = "SELECT * "
                + "FROM uap_mst_s_pol "
                + "ORDER BY id ";
        i.query(sql);

        while (i.resultNext()) {

            Police l = new Police();
            l.setId(i.result().getString("id"));
            l.setParentId(i.result().getString("parent"));
            l.setFullName(i.result().getString("name"));
            l.setShortName(i.result().getString("short"));
            list.add(l);
        }

        i.close();
        return list;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }
    
}
